//var app = getApp();

Page({

  data: {
    onLoad: function () { },
    hiddenmodalput: true,
    _child: "",
    disabled: false,
  },
  //评论弹出框
  modalinput: function () {
    this.setData({
      hiddenmodalput: false //!this.data.hiddenmodalput
    })
  },
  //取消按钮  
  cancel: function () {
    this.setData({
      hiddenmodalput: true
    })
  },
  chan: function (e) {
    this.setData({
      _child: e.detail.value
    })
  },
  //确认  
  confirm: function (a) {
    var that = this;
    var i = a.currentTarget.dataset.id;
    var comment = this.data._child;
    this.setData({
      hiddenmodalput: true
    });
    
    var that = this;
    wx.request({
      url: 'http://139.199.105.136/lovewall/insert_remark',
      //method: "POST",
      data: {
        "message": comment,
        "follow_id": a.currentTarget.dataset.id
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function () {
        wx.request({
          url: 'http://139.199.105.136/lovewall/show?id=' + a.currentTarget.dataset.id,
          data: {},
          header: {
            'content-type': 'application/json'
          },
          success: function (res) {

            console.log(res.data);
            var article = res.data.content;
            // var that = this;

            that.setData({
              Downdetail: res.data[i].remark,
              Industr: res.data[i]
            })
          },
          fail: function (err) {
            console.log(err)
          }
        })
      }

    })
  },


  //点赞
  zan: function (e) {
    console.log(e);
    var that = this;
    var i = e.currentTarget.dataset.id;
    wx.request({
      url: 'http://139.199.105.136/lovewall/insert_lc',
      //method: "POST",
      data: { 'id': e.currentTarget.dataset.id },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },

      success: function () {
        wx.request({
          url: 'http://139.199.105.136/lovewall/show?id=' + e.currentTarget.dataset.id,
          data: {},
          header: {
            'content-type': 'application/json'
          },
          success: function (res) {

            console.log(res.data);
            var article = res.data.content;
            // var that = this;

            that.setData({
              Downdetail: res.data[i].remark,
              Industr: res.data[i]
            })
          },
          fail: function (err) {
            console.log(err)
          }
        })
      }
    });

    that.setData({
      disabled: true
    })

  },
  // 加载日记
  getDiary(params) {
    console.log("Loading diary data...", params);
    var id = params["id"], diary;
    this.setData({
      diary: diary,
    })
  },

  getDetail(id) {
    var that = this;
    var i = id;
    wx.request({
      url: 'http://139.199.105.136/lovewall/show?id=' + id,
      data: {},
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {

        console.log(res.data);
        var article = res.data.content;
        // var that = this;

        that.setData({
          Downdetail: res.data[i].remark,
          Industr: res.data[i]
        })
      },

      fail: function (err) {
        console.log(err)
      }
    })
  },

  onLoad: function (params) {
    var id = params.id;
    
    this.getDetail(id);
  }


})